function is_logged (from_article_page,from_register_page,from_page) {
	var result = document.cookie.match ('(^|;)?'+'username'+'=([^;]*)(;|$)');
	var mobile = isMobile();
	if (result) {
		document.write("<div id=\"welcome\"> Benvenuto " + unescape(result[2]));
		if (!mobile) document.write("<br />");
		if (from_article_page == 'yes') {
			document.write("<form action=\"../../cgi-bin/logout.cgi\" method=\"get\">");
			document.write("<input type=\"hidden\" name=\"fromPage\" value=\"" + from_page + "\"/>");
			document.write("<input type=\"submit\" value=\"Logout\"/>");
			document.write("</form> </div>");
		} else {
			document.write("<form action=\"../cgi-bin/logout.cgi\" method=\"get\">");
			document.write("<input type=\"hidden\" name=\"fromPage\" value=\"" + from_page + "\"/>");
			document.write("<input type=\"submit\" value=\"Logout\"/>");
			document.write("</form> </div>");
		}
	}
	else
		if (from_article_page == 'yes') {
			document.write("<form action=\"../../cgi-bin/authentication.cgi\" method=\"post\">" +
					"<fieldset id=\"fieldset\">" +
					"<legend><strong>LOGIN</strong></legend>" +
					"<label for=\"username\">Username </label>");
			if (!mobile) document.write("<br />");
			document.write("<input name=\"username\" id=\"username\" value=\"\" title=\"Inserisci lo username\" />");
			if (!mobile) document.write("<br /><br />");
			document.write("<label for=\"password\">Password </label>");
			if (!mobile) document.write("<br />");
			document.write("<input type=\"password\" name=\"password\" id=\"password\" value=\"\" title=\"Inserisci la password\" />");
			if (!mobile) document.write("<br /><br />");
			document.write("<label id=\"registerForm\"><a href=\"../../static_html/registration.html\" hreflang=\"it\" title=\"Registrazione\" accesskey=\"r\" >Registrati (r)</a></label>" +
					"<input name=\"submit\" id=\"submitLogin\" type=\"submit\" value=\"Login\" title=\"Effettua il login\" /> " +
					"<input type=\"hidden\" name=\"from_page\" value=\"" + from_page + "\"/>" +
					"</fieldset>" +
			"</form>");
		} else {
			document.write("<form action=\"../cgi-bin/authentication.cgi\" method=\"post\">" +
					"<fieldset id=\"fieldset\">" +
					"<legend><strong>LOGIN</strong></legend>" +
					"<label for=\"username\">Username </label>");
			if (!mobile) document.write("<br />");
			document.write("<input name=\"username\" id=\"username\" value=\"\" title=\"Inserisci lo username\" />");
			if (!mobile) document.write("<br /><br />");
			document.write("<label for=\"password\">Password </label>");
			if (!mobile) document.write("<br />");
			document.write("<input type=\"password\" name=\"password\" id=\"password\" value=\"\" title=\"Inserisci la password\" />");
			if (!mobile) document.write("<br /><br />");
			if (from_register_page == 'yes') {
				document.write("<label id=\"registerForm\">Registrati</label>");
			}
			else {
				document.write("<label id=\"registerForm\"><a href=\"../static_html/registration.html\" hreflang=\"it\" title=\"Registrazione\" accesskey=\"r\" >Registrati (r)</a></label>");
			}
			document.write("<input name=\"submit\" id=\"submitLogin\" type=\"submit\" value=\"Login\" title=\"Effettua il login\" /> " +
					"<input type=\"hidden\" name=\"from_page\" value=\"" + from_page + "\"/>" +
					"</fieldset>" +
			"</form>");
		}
}

function can_comment () {
	var result = document.cookie.match ('(^|;)?'+'username'+'=([^;]*)(;|$)');
	if (result) {
		return true;
	} else {
		return false;
	}
}

function check_server_return() {
	var result = document.cookie.match ('(^|;)?'+'reg_err'+'=([^;]*)(;|$)');
	if (result) {
		document.getElementById('errorUsername_r').style.borderColor="red";
		document.getElementById('usernameRegistration').value="Username non disponibile";
		document.cookie = "reg_err=;expires=Thu, 01-Jan-1970 00:00:01 GMT;path=/";
	}
}
